﻿#pragma once
#ifndef WRTASKDEALER_H
#define WRTASKDEALER_H

//表示任务处理者。
class WRTaskDealer
{
public:
    //执行任务处理，并返回任务的执行状态。
    virtual WR32s doProcess(void* task) = 0;
};

#include "../Runtime/WRErrors.h"

#define WRTASKDEALER(name, taskname, targetname, methodname) \
class name : public WRTaskDealer\
{\
private:\
    targetname* m_target;\
public:\
    inline name(void){}\
    inline explicit name(targetname* target){m_target = target;}\
    inline targetname* target(void) const{return m_target;}\
    inline void target(targetname* value){m_target = value;}\
    WR32s doProcess(void* task)\
    {\
        if (task) return m_target->methodname(*(taskname*)task);\
        return WRErrors::ArgumentNull;\
    }\
};

#endif // WRTASKDEALER_H

